<script id="list-tpl" type="text/html" data-params='{"url":"{:url("rule")}","dataName":"rule","select":"#select-tpl","selectid":"#pid-select"}'>
    {{# layui.each(d.list, function(index, item){ }}
    <tr>
        <td><input type="checkbox" name="id" value="{{ item.id}}" lay-skin="primary"></td>
        <td class="txt-center">{{ item.id}}</td>
        <td>{{ strRepeat('&nbsp;&nbsp;',item.level)}} {{# if(item.level>0){ }} ├&nbsp; {{# } }}<span class="edit" data-params='{"url":"{:url("saverule")}","field":"title","data":"id={{ item.id}}"}'> {{ item.title}}</span>
        </td>
        <td> <span class="edit" data-params='{"url":"{:url("saverule")}","field":"name","data":"id={{ item.id}}"}'>{{ item.name}}</span>
        </td>

        <td><span class="edit" data-params='{"url":"{:url("saverule")}","field":"condition","data":"id={{ item.id}}"}'> {{ item.condition}}</span></td>
        
        <td><input type="checkbox" name="status" lay-skin="switch" lay-text="ON|OFF" {{#if ( parseInt(item.status)){ }}checked="checked" {{# } }} lay-filter="ajax" value="1" data-params='{"url":"{:url("saverule")}","data":"id={{ item.id}}"}'> </td>
        <td>
            <div class="layui-btn-group">
                <button class="layui-btn layui-btn-mini layui-btn-normal modal" data-params='{"content":".add-subcat","area":"600px,auto","title":"添加{{ item.name}}的子分类","data":"pid={{ item.id }}&level={{ item.level+1 }}","action":"add","url":"{:url("saverule")}"}'>
                            <i class="iconfont">&#xe649;</i>添加规则
                        </button>
                <button class="layui-btn layui-btn-mini modal" data-params='{"url": "{:url("saverule")}","content": ".add-subcat","area":"600px,auto","title":"编辑{{ item.name}}分类","type":"1","data":"id={{ item.id }}","bind":"true","action":"edit"}'>
                            <i class="iconfont">&#xe653;</i>编辑
                        </button> 

                <button class="layui-btn layui-btn-mini layui-btn-danger ajax" data-params='{"url": "{:url("delrule")}","action":"del","data":"id={{ item.id}}"}'>
                            <i class="iconfont">&#xe626;</i>删除
                        </button>

            </div>
        </td>
    </tr>
    {{# }); }}

</script>

<script id="select-tpl" type="text/html" data-params='{"dataName":"menu"}'>
    <option value="0" data-level="0">顶级分类</option>
    {{# layui.each(d.list, function(index, item){ }}
    <option value="{{ item.id}}" data-level="{{ item.level}}"> {{ strRepeat('&nbsp;&nbsp;',item.level)}} {{# if(item.level>0){ }} ├&nbsp; {{# } }} {{ item.title}}</option>
    {{# }); }}
</script>